<?php

namespace wicked\core;

abstract class Response
{

    use \wicked\tools\StaticAccessor;

    /** @var string */
    protected static $controller;

    /** @var string */
    protected static $action;

    /** @var array */
    protected static $args = [];

    /** @var string */
    protected static $layout;

    /** @var string */
    protected static $template;

    /** @var array */
    protected static $data = [];


    /**
     * Set path to action
     * @static
     * @param string $path
     * @param array $args
     */
    public static function to($path, $args = [])
    {
        $array =  explode('::', $path);
        static::$controller = $array[0];
        static::$action = isset($array[1]) ? $array[1] : 'index';
        static::$args += $args;
    }


    /**
     * Set default
     * @static
     */
    public static function home()
    {
        static::to(config('default::controller'));
    }


    /**
     * Redirect to the specified url
     * @param String $url
     */
    public static function redirect($url)
    {
        header('Location: ' . url($url));
        exit;
    }

}
